
//AJAX function for the live search box
function showResult(str)
{
if (str.length==0)
  { 
  document.getElementById("livesearch").innerHTML="";
  document.getElementById("livesearch").style.border="0px";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","livesearch.php?q="+str,true);
xmlhttp.send();
}

//Highlight a returned results from the AJAX live search when user does mouseover
function highlight(id){
    document.getElementById(id).style.backgroundColor = 'lightgrey';
}

//Highlight a returned results from the AJAX live search when user does mouseout
function unhighlight(id){
    document.getElementById(id).style.backgroundColor = 'white';
}

//Fill the search box with the name of the person selected from the AJAX live search
function fillsearch(id){
    var clickeddiv = document.getElementById(id);
    var searchbox = document.getElementById('searchbox');
    searchbox.value = clickeddiv.innerHTML;
    
    var myNode = document.getElementById("livesearch");
    myNode.innerHTML = '';
}
//Call the pageload function
 window.onload = pageload;

//Called when the page loads *This function may have to be moved to a seperate JS file
function pageload(){
    //Any functions that need start when the page loads should go here
     alert('unction gets called on page load');
     updatefriendslist();
}

function updatefriendslist(){
     alert('friends list');
}
